import time
from telnetlib import EC

import param
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

from common.Untils import QESDriver

class LoginPage:

    def __init__(self):
        self.url = "http://8.155.1.153:8081/user/login"
        self.driver = QESDriver.driver
        self.driver.get(self.url)
    def GetloginPage(self):
        #不输入用户名直接点击登录
        self.driver.find_element(By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/form/button').click()
        #time.sleep(2)
        #QESDriver.GetScreenShot()
    #输入正确的账户，错误的密码并进行截图
        #查找用户名输入栏并输入“lindong”
        self.driver.find_element(By.XPATH,'//*[@id="username"]').send_keys("lindong")
        # 查找密码输入栏并输入错误密码“123456”
        self.driver.find_element(By.XPATH,'//*[@id="password"]').send_keys("123456")
        # 使用错误密码并点击登录然后截图展示
        self.driver.find_element(By.XPATH,'//*[@id="root"]/div/div[2]/div[2]/div/form/button/span').click()
        time.sleep(2)
        #QESDriver.GetScreenShot()
    # 使用正确密码登录并截图查看
        # 先清空，再输入正确密码
        QESDriver.ClearInput(self.driver.find_element(By.CSS_SELECTOR,'#password'))
        time.sleep(2)
        self.driver.find_element(By.XPATH, '//*[@id="password"]').send_keys("sss123")
        self.driver.find_element(By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/form/button').click()
        time.sleep(2)
        #QESDriver.GetScreenShot()
